package com.aspose.cells;

import java.util.ArrayList;
import java.util.HashMap;

class zafc extends zafb {
   private StringBuilder b = new StringBuilder();
   private StringBuilder c = new StringBuilder();
   private zaew d;
   private boolean e = false;
   private boolean f = false;
   private boolean g = false;
   private boolean h = false;
   private IStreamProvider i;

   public void a(IStreamProvider var1) {
      this.i = var1;
      this.d.a(this.i);
   }

   public zafc(String var1, Workbook var2, Encoding var3) throws Exception {
      this.d = new zaew(var1, var2);
      this.a((IStreamProvider)(new zbpr()));
      this.a(var2);
      com.aspose.cells.b.a.d.ze var4 = com.aspose.cells.b.a.d.zd.b(var1);
      this.a((com.aspose.cells.b.a.d.zn)(new com.aspose.cells.b.a.d.zn(var4, var3)));
   }

   public zafc(String var1, Workbook var2, HTMLLoadOptions var3, Encoding var4) throws Exception {
      this.d = new zaew(var1, var2, var3);
      this.a((IStreamProvider)(new zbpr()));
      this.a(var2);
      com.aspose.cells.b.a.d.ze var5 = com.aspose.cells.b.a.d.zd.b(var1);
      this.a((com.aspose.cells.b.a.d.zn)(new com.aspose.cells.b.a.d.zn(var5, var4)));
   }

   public zafc(com.aspose.cells.b.a.d.zm var1, Workbook var2, zaew var3, String var4, Encoding var5) throws Exception {
      this.d = var3;
      this.a((IStreamProvider)(new zbpr()));
      this.d.f();
      this.a(var2);
      this.a((com.aspose.cells.b.a.d.zn)(new com.aspose.cells.b.a.d.zn(var1, var5)));
      this.d.d(var4);
   }

   public zafc(com.aspose.cells.b.a.d.zm var1, Workbook var2, HTMLLoadOptions var3, Encoding var4) throws Exception {
      this.a(var2);
      this.d = new zaew(var1, var2, var3);
      this.a((IStreamProvider)(new zbpr()));
      this.a((com.aspose.cells.b.a.d.zn)(new com.aspose.cells.b.a.d.zn(var1, var4)));
   }

   public void a(zaew var1, Workbook var2, Encoding var3) throws Exception {
      ArrayList var4 = var1.g();
      HashMap var5 = var1.d();
      com.aspose.cells.b.a.a.zc var6 = com.aspose.cells.b.a.a.zf.a(var5);

      while(var6.c()) {
         String var7 = null;
         String var8 = null;
         String[] var9 = new String[]{var7};
         String[] var10 = new String[]{var8};
         this.a((String)var6.a(), var9, var10);
         var7 = var9[0];
         var8 = var10[0];
         var1.e().a(var1.e().F().get(var7));
         com.aspose.cells.b.a.d.zm var11 = (com.aspose.cells.b.a.d.zm)var6.b();
         zafc var12 = new zafc(var11, var2, var1, (String)var6.a(), var3);
         var12.m();
         var12.q().e().z();
         var11.a();
      }

   }

   private void a(String var1, String[] var2, String[] var3) {
      var2[0] = var3[0] = null;
      String[] var4 = com.aspose.cells.b.a.zv.d(var1, '\b');
      var2[0] = var4[0];
      var3[0] = var4[1];
   }

   public void m() throws Exception {
      this.s();
      char var1 = ' ';
      this.b(this.g());

      while(true) {
         while(true) {
            while(!this.f()) {
               if (this.l() == '<') {
                  char var2 = this.g();
                  if (var2 == '!' && (var1 = this.g()) == '-' && this.g() == '-') {
                     this.u();
                     this.n();
                  } else if (var2 == '!' && var1 == '[') {
                     this.v();
                  } else {
                     this.c(var2);
                     this.p();
                  }
               } else if (this.e) {
                  this.t();
                  if (!this.f) {
                     this.o();
                  }
               } else {
                  this.b(this.g());
               }
            }

            return;
         }
      }
   }

   public void n() throws Exception {
      this.d.b(com.aspose.cells.b.a.zr.a(this.b));
   }

   public void o() throws Exception {
      if (this.c.length() > 0) {
         this.d.a(com.aspose.cells.b.a.zr.a(this.c));
      }

   }

   public void p() throws Exception {
      this.r();
      if (com.aspose.cells.b.a.zr.a(this.j()).startsWith("/")) {
         this.d.b(com.aspose.cells.b.a.zr.a(this.j()).toLowerCase(), this.d());
      } else {
         this.d.a(com.aspose.cells.b.a.zr.a(this.j()).toLowerCase(), this.d());
      }

   }

   private void r() throws Exception {
      this.e = true;
      if ("script".equals(com.aspose.cells.b.a.zr.a(this.j()).toLowerCase())) {
         this.f = true;
      }

      if ("/script".equals(com.aspose.cells.b.a.zr.a(this.j()).toLowerCase())) {
         this.f = false;
      }

      if (!this.g && "table".equals(com.aspose.cells.b.a.zr.a(this.j()).toLowerCase())) {
         this.d.e().m();
         this.g = true;
      }

      if (this.g && "/table".equals(com.aspose.cells.b.a.zr.a(this.j()).toLowerCase())) {
         this.g = false;
      }

      if (!this.h && "head".equals(com.aspose.cells.b.a.zr.a(this.j()).toLowerCase())) {
         this.h = true;
      }

      if (this.h && "/head".equals(com.aspose.cells.b.a.zr.a(this.j()).toLowerCase())) {
         this.h = false;
      }

      if (this.h && "xml".equals(com.aspose.cells.b.a.zr.a(this.j()).toLowerCase())) {
         this.b.delete(0, 0 + this.b.length());
         this.b.append("<xml>");

         char var1;
         for(; !this.f(); this.b.append(var1)) {
            var1 = this.g();
            if (var1 == '<') {
               this.b.append(var1);
               var1 = this.g();
               if (var1 == '/') {
                  this.b.append(var1);
                  var1 = this.g();
                  char var2 = this.g();
                  char var3 = this.g();
                  if (var1 == 'x' && var2 == 'm' && var3 == 'l') {
                     this.b.delete(this.b.length() - 1, this.b.length() - 1 + 1);
                     this.b.append("/xml><![endif]");
                     break;
                  }

                  this.b.append(var1);
                  this.b.append(var2);
                  this.b.append(var3);
                  var1 = this.g();
               }
            }
         }

         this.n();
         this.b(this.g());
      }

   }

   public zaew q() {
      return this.d;
   }

   private void s() {
      this.d.c();
   }

   private void t() throws Exception {
      char var1 = this.g();
      if (var1 != '\r' && var1 != '\n' && var1 != '<') {
         this.c.delete(0, 0 + this.c.length());
         this.c.append(var1);

         while(!this.f()) {
            var1 = this.g();
            if (var1 == '<') {
               this.b(var1);
               break;
            }

            this.c.append(var1);
         }

      } else {
         this.b(var1);
         this.c.delete(0, 0 + this.c.length());
      }
   }

   private void c(char var1) throws Exception {
      this.j().delete(0, 0 + this.j().length());
      this.c();
      this.j().append(var1);

      while(!this.f()) {
         char var2 = this.g();
         if (var2 == '>') {
            this.b(var2);
            return;
         }

         if (a(var2)) {
            break;
         }

         this.j().append(var2);
      }

      this.b(this.e());

      while(this.l() != '>') {
         String var4 = this.h();
         if (this.l() == '>') {
            this.a(var4, "");
            break;
         }

         String var3 = this.i();
         this.a(var4, var3);
      }

   }

   private void u() throws Exception {
      this.b.delete(0, 0 + this.b.length());

      char var1;
      for(; !this.f(); this.b.append(var1)) {
         var1 = this.g();
         if (var1 == '-') {
            this.b.append(var1);
            var1 = this.g();
            if (var1 == '-') {
               var1 = this.g();
               if (var1 == '>') {
                  this.b.delete(this.b.length() - 1, this.b.length() - 1 + 1);
                  break;
               }
            }
         } else if (var1 == '>' && com.aspose.cells.b.a.zr.a(this.b).endsWith("--")) {
            this.b.delete(this.b.length() - 2, this.b.length() - 2 + 2);
            break;
         }
      }

      this.b(this.g());
   }

   private void v() throws Exception {
      this.b.delete(0, 0 + this.b.length());

      while(!this.f()) {
         char var1 = this.g();
         if (var1 == ']' && this.g() == '>') {
            break;
         }

         this.b.append(var1);
      }

      this.b(this.g());
   }

   private void a(Workbook var1) {
      for(int var2 = 0; var2 < var1.getWorksheets().getCount(); ++var2) {
         var1.getWorksheets().get(var2).setGridlinesVisible(false);
      }

   }
}
